﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
namespace DAO
{
    public class Abstract
    {
        protected static OleDbConnection GetConnection()
        {
            string connectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb;Jet OLEDB:Database Password=436499";
            OleDbConnection connect = new OleDbConnection(connectionstring);
            return connect;
        }
        protected static bool Query(string _query)
        {
            OleDbConnection conn = null;
            bool res = true;
            try
            {
                conn = GetConnection();
                conn.Open();
            }
            catch
            {
                throw new Exception("Connect error!");
            }
            try
            {
                OleDbCommand cm = new OleDbCommand(_query, conn);
                cm.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                res = false;
            }

            if (conn.State == System.Data.ConnectionState.Open)
                conn.Close();
            return res;
        }
        
    }
}
